'''urllib_get请求quote处理浏览器编解码
例如： wd=周杰伦 quote()后 wd=%E5%91%A8%E6%9D%B0%E4%BC%A6'''

import urllib.request
import urllib.parse

wd = '周杰伦'
print('将周杰伦转码：', urllib.parse.quote(wd)) # %E5%91%A8%E6%9D%B0%E4%BC%A6

url = 'https://www.baidu.com/s?wd='+urllib.parse.quote(wd)
print(url)
# 请求定制Request
headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36'
}
request = urllib.request.Request(url=url, headers=headers)
# 获取返回体
response = urllib.request.urlopen(request)
content = response.read().decode('utf-8')
print(content)







